package com.linln.modules.shopsService.domain;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.hibernate.annotations.Columns;
import org.hibernate.annotations.Where;
import org.springframework.boot.configurationprocessor.json.JSONException;
import org.springframework.boot.configurationprocessor.json.JSONObject;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.io.Serializable;
import java.util.Map;
import javax.persistence.*;

/**
 * @author zsc
 * @date 2020/11/19
 */
@Data
@Entity
@Table(name = "tbl_shop")
@EntityListeners(AuditingEntityListener.class)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Shops implements Serializable {
    // 主键ID
    @Id
    private String shopId;
    // 区域序号
    private String areaId;
    // 账户序号
    private String accountId;
    // 店铺名称
    private String shopName;
    // 店铺类型
    private String shopType;
    //店铺类型名称
    @Transient
    private String shopTypeName;
    // 联系人名称
    private String contactsName;
    // 电话
    private String phone;
    // 备用电话
    private String sparePhone;
    // 得分
    private Double score;
    // 经度
    private String longitude;
    // 纬度
    private String latitude;
    // 地址
    private String address;
    // 营业状态
    private String openingStatus;
    // 营业时间
    private String openingHours;
    // 扩展字段
    @Column(columnDefinition = "json")
    //序列化是忽略这个属性
    @JsonIgnore
    private String props;
    //店铺图片
    private String shopPicture;
    // 审核标记
    private String auditMark;
    //创建日期
    private String createDate;
    //逻辑删除
    private String delFlag;
    //入驻店铺申请者id
    private String shopCreateUserId;

    //店铺详情
    private String ShopDetails;

    @JsonGetter("props")
    public Map getPropsJson() throws JSONException {
        return JSON.parseObject(props, Map.class);
    }

//    public JSONObject getProps() {
//        try {
//            return new JSONObject(props);
//        } catch (JSONException e) {
//            return null;
//        }
//    }
//
//    public void setProps(String props) {
//        this.props = props;
//    }
}
